﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/SiteMain.Master" Inherits="System.Web.Mvc.ViewPage<TvGuide.UI.Models.ProgramData>" %>
<%@ Import Namespace="System.Web.Script.Serialization" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <%= ViewData["title"]%>
</asp:Content>


<asp:Content ID="HomeFBOpenGraphTags" ContentPlaceHolderID="FBOpenGraphTagsHolder" runat="server">
    <meta property="og:url" content="<%=ViewData["og_url"] %>" />
    <meta property="og:title" content="<%=TVGuide.Common.Main.MAINTITLE_LBL%>"/>
    <meta property="og:image" content="<%=ViewData["og_img"] %>"/>
</asp:Content>


<asp:Content ID="HomePageMetaTags" ContentPlaceHolderID="MetaTagsHolder" runat="server">
    <meta name="Description" content="<%=ViewData["chanalname"] %> - Watch <%=ViewData["chanalname"] %> online and TV programs listings for Armenian TV channels. 
                                      Армения ТВ онлайн - Смотреть телевидения и программы телепередач." 
    />
    <meta name="keywords" content="<%=ViewData["chanalname"] %>, Армения ТВ, Armenia TV, <%=ViewData["chanalname"] %> tv online, Armenia TV Online, Тв каналы Армении онлайн, 
                                    Армения Онлайн ТВ, смотреть армения тв, армения тв сериалы, армянские программы телепередач,
                                    Free, music, tv, Haykakan, hayeren tv, smotret tv online,
                                    armenian tv channel, online, смотреть ТВ Онлайн,
                                    դիտել, հայկական, ծրագիր, օնլայն հ1, օնլայն շանթ" />
    <meta name="revisit-after" content="1 days" />
    <meta name="robots" content="index,follow" />
</asp:Content>

<asp:Content ID="HomeH1TagContent" ContentPlaceHolderID="H1TagContent" runat="server">
    <% = ViewData["h1content"] %> 
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<script type="text/javascript">        
    var model = <%=new JavaScriptSerializer().Serialize(Model)%>;
    var ppp = model.OnAir;

    $(function () {
        $(".Home-page_Channel_Div_Element").tooltip({
            effect: 'slide',
            position: 'center right',
            offset: [10, 0],
            
        });

    });
    
    $(function() {
        for(var i = 0; model.NowRunProgsCompletePersList && i < model.NowRunProgsCompletePersList.length; i++)
        {
            $( "#progressbar_" + i).progressbar({
			    value: model.NowRunProgsCompletePersList[i]
		    });
        }
	});

   

</script>

    <div>
   
        <div class="Home-page_Channel_Div">
             <div class="watch-online-link">                
                 <a  class="Home-page_Prog_Div_HeadMenu_Buttons_Online" href="/<%=ViewData["lng"]%>/Watch/H1" >
                    <div style="width:38px;height:20px;float:left;margin-top:1px;margin-right:10px;background:url('/content/new_icon.gif') no-repeat;"></div>
                    <%= TVGuide.Common.Main.WATCHONLINE_LBL %>
                 </a>
             </div>

            <% foreach (var ch in Model.ChList) 
               {  
   
            %>
            <div class="Home-page_Channel_Div_Element_Container">
            <% 
                bool isselected = (ViewData["selch"].ToString() == ch.ID.ToString() && Convert.ToBoolean(ViewData["Runing"]) == false);
                 %>
               <a href="/<%:ViewData["lng"] %>/schedule/<%:ch.Name %>-tv/<%:ch.ID %>/<%:ViewData["selday"] %>">
                <div style='background-color:<%=isselected?"#E0E0E0":"" %>' class="Home-page_Channel_Div_Element" title=" <%: ch.DispName %>" ">
                   
                    <img class="Home-page_Channel_Div_Element_Img" alt="Armenia TV" src="<%: ch.ImgUrl %>" />
                </div>
                </a>
                <%--<div id="<%: ch.ID %>" alt ="<%: Model.Lng %>" style='background-color:<%=isselected?"#E0E0E0":"" %>' class="Home-page_Channel_Div_Element" title=" <%: ch.DispName %>" url="<%: Url.Action("GetProg","Home",new {lng="arm",ch=ch.ID,id=(int)DateTime.Now.AddHours(Model.ZoneHour).DayOfWeek}) %>">
                   
                    <img class="Home-page_Channel_Div_Element_Img" alt="<%: ch.Name %>" src="<%: ch.ImgUrl %>" />
                </div>--%>
            </div>
            <%} %>
        </div>
        <div class="Home-page_Prog_Div">
            <div class="Home-page_Prog_Div_HeadMenu" id="home_prog_day_chooser">
            <%  int i = 0; 
                string selected = "selected_day";  
                bool isDaysel; 
            %>
                <% foreach (string ss in Model.WeekDay)
                   {
                       isDaysel = false;
                       if (i == Convert.ToInt32(ViewData["selday"].ToString()) && Convert.ToBoolean(ViewData["Runing"]) == false)
                       {
                           selected = "selected_day";
                           isDaysel = true;
                       }
                       else
                       {
                           selected = "not_selected_day";
                       }
                %>
                       
                <%--<div id="<%:selected %>"  class="Home-page_Prog_Div_HeadMenu_Buttons" url="<%: Url.Action("GetProg","Home",new {lng="arm",ch=Int32.Parse(ViewData["selch"].ToString()),id=i})   %>">
                    <%: ss%></div>--%>
                    <a href="/<%:ViewData["lng"] %>/schedule/<%:ViewData["selch"] %>/<%:i %>">
                    <div id="<%:selected %>" class="Home-page_Prog_Div_HeadMenu_Buttons" >
                    <%: ss%>
                    </div>
                    </a>
                <%i++;
           } %>
           
            </div>

            <div style="clear" id="catchooser"><% Html.RenderPartial("CategoryWidget"); %></div>
            <div class="Home-page_Prog_Div_ProgramsAnnouncements">
               
                <div class="Home-Home-page_NowRuning_Div">
                    <a href="/<%:ViewData["lng"] %>" id="NowRun" class="NowRun Home-page_Prog_Div_HeadMenu_Buttons">                        
                        <%= Model.OnAir %>
                    </a>                    
                    <div class="Home-Home-page_NowRuning_Div_Input">
                        <input type="text"  id="amount" readonly="readonly" name="<%: DateTime.Now.AddHours(Model.ZoneHour).Hour %>" value="<%: Model.OnAirVal %>" style="border: 0;
                            color: #094B90; font-weight: bold;" />
                        <div id="slider" style="display:<%= ViewData["displayVal"] %>">
                        </div>
                    </div>
                </div>
                
                <div class="Home-page_Prog_Div_Programs">


                <%= Model.ProgsListHtml  %>
                </div>
                <div class="Home-page_Prog_Div_Announcements">
                </div>
            </div>
            <div id="LoadingDiv" class="Hidden"><br/><br/>
                <img alt="Please wait. Loading..." id="Load"  src="<%:Url.Content("~/Content/loading.gif") %>" />
            </div>
        </div>
    </div>
    
    <script type="text/javascript">
        $(function () {
            $("#slider").slider({
                value: StartValue($("#amount").attr("name")),
                // $("#amount").attr("name")<8? 47-2*$("#amount").attr("name"): 2*($("#amount").attr("name"))-16,
                min: 0,
                max: 47,
                step: 1,
                slide: function (event, ui) {
                    $("#amount").val(formatTime(ui.value));
                },

                stop: function (event, ui) {

                    if (ui.value == $("#amount").attr("name"))
                        return;
                    $("div.Home-page_Prog_Div_Programs").html("");
                    $("#LoadingDiv").removeClass("Hidden");
                    var lng = $("#langlbl").val();
                    var url = "/" + lng + "/Home/GetRuning/" + ui.value + "/1";
                    // $("#lastviewlink").val(url);
                    $.ajax(
                        {
                            url: url,
                            type: "post",
                            data: $(this).serialize(),
                            success: function (PrData) {
                                $("div.Home-page_Prog_Div_Programs").html(PrData.ProgsListHtml);
                                ProgCatChbxChecker();
                                //document.getElementById('amount').name = ui.value;
                                
                                $("#LoadingDiv").addClass("Hidden");
                            }
                        });

                }

            });
            //  var vall = $("#slider").slider("value");
            $("#amount").val($("#amount").attr("name") + ":" + "00");

        });

        ////////////////////////////StartValue function////////////

        function StartValue(val) {
            var ret;
            if (val == 0)
                val = 24;
            if (val < 8)
                ret = 47 - 2 * (8 - val);
            if (val >= 8)
                ret = 2 * val - 16

            document.getElementById('amount').name = ret;
            return ret;

        }


        /////////////////////////////FormatTIme function//////////////
        function formatTime(val) {
            var vall = 8 + Math.floor(val / 2);
            if (vall > 24)
                vall = vall - 24;


            var retstr;

            if (vall < 10)
                retstr = "0" + vall.toString();
            else if (vall == 24)
                retstr = "00";
            else
                retstr = vall.toString();

            if (30 * (val % 2) == 0)
                retstr = retstr + ":00";
            else
                retstr = retstr + ":" + (30 * (val % 2)).toString();

            return retstr;
        }
        ////////////////////////// FormatVal function////////////////////
        function formatVal(val) {
            var vall;
            if (val < 8)
                vall = 46 - 2 * vall;
            else
                vall = 2 * vall;
            return vall;
        }


        /////////////////////////////////// Reset Slider //////////////////////

        function ResetSlider() {

            $(function () {
                $("#slider").slider({
                    /* value: $("#amount").attr("name") < 8 ? 47 - 2 * $("#amount").attr("name") : 2 * ($("#amount").attr("name")) - 16, */
                    value: $("#amount").attr("name"),
                    min: 0,
                    max: 47,
                    step: 1,
                    slide: function (event, ui) {
                        $("#amount").val(formatTime(ui.value));
                    },

                    stop: function (event, ui) {

                        $("div.Home-page_Prog_Div_Programs").html("");
                        $('#LoadingDiv').show();
                        var lng = $("#langlbl").val();
                        var url = "/" + lng + "/Home/GetRuning/" + ui.value + "/1";
                        // $("#lastviewlink").val(url);


                        $.ajax(
                        {
                            url: url,
                            type: "post",
                            data: $(this).serialize(),
                            success: function (PrData) {
                                $("div.Home-page_Prog_Div_Programs").html(PrData.ProgsListHtml);
                                ProgCatChbxChecker();
                                $('#LoadingDiv').hide();

                            }
                        });

                    }

                });
                //  var vall = $("#slider").slider("value");
                $("#amount").val($("#amount").attr("name") + ":" + "00");

            });
        }
          
    </script>
</asp:Content>
